<template>
  <div class="contents">
    <PanelTitle title="供应商排名" />

    <div ref="maps" class="maps mt"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import echarts from "@/components/echarts";
import { fitChartSize } from "@/utils/dataUtil.js";
import PanelTitle from "../../component/PanelTitle.vue";
import http from "@/api/http";
import { env } from "@/utils/env";
import LoopScroll from "@/components/loopScroll.vue";
import { countOrderCompany } from "@/api/orderApi";
const maps = ref(null);
const list = ref([
  { name: '河北百运钢板网制造有限公司', money: '144' },
  { name: '佛山市顺德区厚盈骏业五金丝网制造有限公司', money: '120' },
  { name: '安平县泊林金属丝网有限公司', money: '103' },
  { name: '上海灿炜实业有限公司', money: '94' },
  { name: '上海永顺祥实业有限公司', money: '74' },
  { name: '天津展翅钢管有限公司', money: '44' },

  
])

onMounted(async () => {
  let res = await countOrderCompany({})
  
  res.data.sort((a:any, b:any) => a.money - b.money)
  let yData = res.data.map((item:any) => {
    return item.companyName.substring(0, 8) + '...';
  });

  let seriesData = res.data.map((item:any) => {
    return item.money / 1000000;
  });
    var myChart = echarts.init(maps.value);

  myChart.setOption({
    tooltip: {
      show: true,
      trigger: "axis",
    },
    grid: {
      left: "3%",
      right: "10%",
      bottom: "10%",
      top: "5%",
      containLabel: true,
    },
    title: {
      text: "单位：万",
      textStyle: {
        color: "#fff",
        fontWeight: 500,
        fontSize: fitChartSize(9),
      },
      right: fitChartSize(10),
    },
    xAxis: [
      {
        type: "value",
        splitNumber: 4,
        splitLine: {
          lineStyle: {
            color: "rgba(255,255,255,0.09)", //线条颜色
            // type: "dashed", //线条样式，默认是实现，dashed是虚线
          },
        },
        min: 0,
        axisLabel: {
          textStyle: {
            color: "#7AFFFD",
            fontSize: fitChartSize(9),
          },
        },
      },
    ],
    yAxis: [
      {
        type: "category",
        data: yData,
        axisLabel: {
          textStyle: {
            color: "#7AFFFD",
            fontSize: fitChartSize(9),
          },
        },
        axisPointer: {
          type: "shadow",
        },
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
      },
    ],
    series: [
      {
        type: "bar",
        barWidth: fitChartSize(14),
        backgroundStyle: {
          color: "rgba(110, 193, 244, 1)",
        },
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: "rgba(55, 137, 255, 0.2)",
              },
              {
                offset: 1,
                color: "rgba(55, 137, 255, 1)",
              },
            ]),
          },
        },
        data: seriesData,
      },
    ],
  });
})

</script>


<style scoped lang="scss">
.contents {
  background: linear-gradient(to bottom,
      rgba(5, 79, 99),
      rgba(5, 79, 99, 0.1),
      rgba(5, 79, 99));
  border-radius: vh(8);
  border: vh(1) solid rgba(6, 112, 180, 1);

}

.mt {
  margin-top: vh(-40);
  color: #2cd7bc;
  font-size: vh(12);
  line-height: vh(20);
  padding: vh(10);
  height: 32vh;

}



.infoPanel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0 vw(15) 0;

  >div {
    box-sizing: border-box;
    width: vw(160);
    height: vh(80);
    background: rgba(9, 36, 44, 0.4);
    border: vh(1) solid #43e7ff;
    padding: 0 vw(20) 0px;
    margin: vh(6) 0;
  }

  .infoTitle {
    color: #fff;
    font-size: vh(10);
    line-height: vh(30);
  }

  .infoNums {
    line-height: vh(20);
  }

  .infoNumss {
    line-height: vh(36);
  }

  .infoNum {
    color: #adffd7;
    font-size: vh(26);
    font: SourceHanSansCN-Bold;
  }

  .infoUnit {
    color: #adffd7;
    font-size: vh(16);
    font: SourceHanSansCN-Bold;
    margin-left: vw(4);
  }

  .infoSub {
    font-weight: 400;
    font-size: vh(10);
    color: #adffd7;
    line-height: vh(20);
  }
}

.time-line {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
}

.year {}

.circle-line {}

.circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2cd7bc;

}

.line {
  height: 100%;
  border-left: 1px dashed #2cd7bc;
  margin: 0 auto;
  width: 0;
}

.text {
  width: 70%;
  padding: 0 0 2vh 0;
}




.loop-scroll {
  height: 30vh;
  width: vw(344);
  margin: 0 auto;
}

table {
  width: vw(344);
  margin: 0 auto;
}

th {
  color: #fff;
  background: rgba(50, 200, 167, 0.45);
  min-width: vw(60);
  line-height: vh(20);
  padding: vh(9) vw(9);
}

table,
th,
td {
  color: #2cd7bc;
  line-height: vh(14);
  padding: vh(9) vw(9);

  border: vh(1) solid #2cd7bc;
  border-collapse: collapse;

  font-family: Source Han Sans CN;
  font-weight: 500;
  font-size: vh(12);
  text-align: center;
}
</style>